/**
 *
 */
package com.spark.demostream.producter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;


/**
 * 发送者
 * @author mazhen
 *
 */
@EnableBinding(value={SendMsg.class})
@Service
public class SendMsgImpl {

    private static Logger logger = LoggerFactory.getLogger(SendMsgImpl.class);

    @Autowired
    private SendMsg sendMsg;

    public void sendMessage(Object meg){
        // header 中匹配 topic模式
        Message<String> test = MessageBuilder.withPayload("test").setHeader("str","a.handle.b").build();
        sendMsg.logoutput().send(test);
        System.out.println("消息发送完成");
    }
}

